package com.cenarius.game.map;

import java.net.UnknownHostException;
import java.util.Map;

import com.cenarius.game.mongo.Dbs;
import com.mongodb.BasicDBList;
import com.mongodb.BasicDBObject;
import com.mongodb.BasicDBObjectBuilder;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class Maps {

	public static void generateSampleMapData() {
		Integer xFrom = -200, xTo = 200, yFrom = -200, yTo = 200;
		DB db = Dbs.getDB("tgs");
		db.dropDatabase();
		DBCollection maps = db.getCollection("maps");
		maps.drop();
		ProvincialMap map = new ProvincialMap();
		map.put("code", "cn_51");
		map.put("size", new RangedSize(xFrom, xTo, yFrom, yTo));
		maps.save(map);

		DBCollection sichuan = db.getCollection("map_cn_51");
		for (Integer x = xFrom; x <= xTo; x++) {
			for (Integer y = yFrom; y <= yTo; y++) {
				BasicDBObject cell = new BasicDBObject();
				cell.put("mapCode", "cn_51");
				cell.put("x", x);
				cell.put("y", y);
				cell.put("cellType", "desert");
				cell.put("cellType2", "desert");
				cell.put("cellType3", "desert");
				cell.put("cellType4", "desert");
				cell.put("cellType5", "desert");
				cell.put("cellType6", "desert");
				cell.put("cellType7", "desert");
				cell.put("cellType8", "desert");
				cell.put("cellType9", "desert");
				cell.put("cellType0", "desert");
				sichuan.save(cell);
			}
		}
	}

	/**
	 * @param args
	 * @throws MongoException
	 * @throws UnknownHostException
	 */
	public static void main(String[] args) throws UnknownHostException,
			MongoException {
		Maps.generateSampleMapData();
	}

}
